<?php
    // 添加成员信息
    header("Content-type:text/html;charset=utf-8");
    $mysqli = new mysqli("localhost","root","root","materialadmin");
    if($mysqli->connect_errno != 0){
        die();
    };

    $role = $_POST["role"];
    $department = $_POST["department"];
    $superior = $_POST["superior"];
    $name = $_POST["name"];

    
    // $role = $_GET["role"];
    // $department = $_GET["department"];
    // $superior = $_GET["superior"];
    // $name = $_GET["name"];

    $sql = "insert into rolemanagement(role,superior,department,name) values('{$role}','{$superior}','{$department}','{$name}')";

    $res = $mysqli->query($sql);
    
    // print_r($res);

    if ($res === TRUE){
        $data["code"] = 3000;
        $data['msg']='添加成功';
    }else{
        $data["code"] = 3001;
        $data['msg']='未知错误';
    }
    echo json_encode($data);
?>